using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CAIR.Lib;

namespace CAIR.UI
{
    public partial class Main : Form
    {
        ImageResize _resizer;
        public Main()
        {
            InitializeComponent();
        }

        private void Main_Load(object sender, EventArgs e)
        {
        }

        private void btnApply_Click(object sender, EventArgs e)
        {
            DateTime dateTime = DateTime.Now;
            _resizer.Resize(double.Parse(txtNewWidth.Text), double.Parse(txtNewHeight.Text));
            pictureBox1.Image = _resizer.InternalImage;
            TimeSpan timeSpan = DateTime.Now - dateTime;
            MessageBox.Show(timeSpan.Seconds.ToString());
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlgOpen = new OpenFileDialog();
            if (dlgOpen.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.Image = Bitmap.FromFile(dlgOpen.FileName);
                _resizer = new ImageResize(pictureBox1.Image as Bitmap);
                txtNewWidth.Text = pictureBox1.Image.Width.ToString();
                txtNewHeight.Text = pictureBox1.Image.Height.ToString();

                btnApply.Enabled = true;
            }
        }
    }
}